const path = require('path')
const htmlWebpackPlugin = require("html-webpack-plugin")
const CleanWebpackPlugin = require("clean-webpack-plugin")
module.exports = {
	entry: './src/index.js',
	mode: "development",
	devServer: {
		contentBase: path.join(__dirname, 'dist'),
		// 压缩 是否开启
		compress: true,
		port:9999,
		open: true
	},
	module: {
		rules: [
			{
				test: /\.(jpg|png|gif)$/,
				use: {
					loader: 'url-loader',
					options: {
						name: '[name]_[hash].[ext]',
						outputPath: 'images/',
						limit: 102400
					}
				} 
			},
			{
				test: /\.scss$/,
				use: [
					"style-loader",
					{
						loader: "css-loader",
						options: {
							importLoaders: 2,
							modules: true
						}
					},
					'sass-loader',
					"postcss-loader"]
			},
			{
				test: /\.ttf$/,
				use: {
					loader: 'file-loader'
				}
			}]
	},
	plugins: [new htmlWebpackPlugin({
		template: 'src/index.html'
	}), new CleanWebpackPlugin(['dist'])],
	output: {
		filename: 'main.js',
		path: path.resolve(__dirname,'dist')
	},
  };
